import { remove } from 'nprogress'
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: '', // 保存token字符串
    illustrateValue: '', //不通过 认证说明 输入框的值
    orderData: null,
    isNewMessage:false, //消息 是否有新消息
    phoneNumber:'',

  },
  getters: {

  },
  mutations: {
    getPhoneNumber(state,payload){
      state.phoneNumber=payload.phoneNumber
    },
    /** 保存token */
    saveToken(state, payload) {
      state.token = payload.token

      if (payload.checked) {
        localStorage.setItem('token', payload.token)
      } else {
        sessionStorage.setItem('token', payload.token)
      }

    },
    // 保存自行建单数据
    saveCreateOrder(state, data) {
      state.orderData = data
      localStorage.setItem('orderData', data)
    },
    saveIllustrateValue(state, illustrateValue) {
      state.illustrateValue = illustrateValue
    },
    deleteToken(state) {
      state.token = '',
        sessionStorage.removeItem('token')
      localStorage.removeItem('token')
    }
  },
  actions: {
  },
  modules: {
  }
})
